<script lang="ts" setup>
import { ElMessage } from "element-plus";
import { complete } from "/@/api/warehousing";

type Props = {
  modelValue: boolean;
  formData: any;
};
const props = withDefaults(defineProps<Props>(), {
  modelValue: false,
  formData: () => ({})
});

const emit = defineEmits(["update:modelValue", "submit-success"]);
const inputHandle = val => {
  emit("update:modelValue", val);
};

const submit = () => {
  complete(props.formData).then(() => {
    ElMessage({
      type: "success",
      message: "添加成功"
    });
    inputHandle(false);
    emit("submit-success");
  });
};
</script>

<template>
  <el-dialog
    :modelValue="modelValue"
    @update:modelValue="inputHandle"
    title="添加完成时间"
    width="20%"
  >
    <span>
      <el-form :model="formData" label-width="auto" label-position="left">
        <el-form-item label="完成时间:">
          <el-date-picker
            v-model="formData.completion_time"
            type="date"
            format="YYYY-MM-DD"
            value-format="YYYY-MM-DD"
          />
        </el-form-item>
      </el-form>
    </span>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="inputHandle(false)">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </span>
    </template>
  </el-dialog>
</template>
